package debtbundler.mathematics;

import static org.junit.Assert.*;

import org.junit.BeforeClass;
import org.junit.Test;

import debtbundler.mathematics.Combinations;

public class CombinationsTest {
	
	@BeforeClass 
	public static void enableLogging() {
		debtbundler.logging.ConfigurationReader.setDefaultConf();
	}

	@Test
	public void testGetCombinations() {
		// Initialize an object array with 6 different integers
		Integer[] integers = new Integer[6];
		for (int i=0; i<integers.length; ++i) {
			integers[i] = i+1;
		}
		
		// Generate all the 3-combinations of the set of 6 integers
		Object[][] combinations = Combinations.getCombinations(integers, 3);
		
		// Print the result
		for (int i=0; i<combinations.length; ++i) {
			System.out.print("#" + (i+1) + ":\t");
			for (int j=0; j<combinations[i].length; ++j) {
				System.out.print(combinations[i][j]+"\t");
			}
			System.out.println();
		}
		
		assertEquals("The correct number of combinations must be generated", 20, combinations.length);
	}
	
	@Test
	public void testGetCombinationIndices() {
		// Initialize an object array with 6 different integers
		Integer[] integers = new Integer[6];
		for (int i=0; i<integers.length; ++i) {
			integers[i] = i+1;
		}
		
		// Generate all the 3-combinations of the set of 6 integers
		int[][] combinations = Combinations.getCombinationIndices(integers, 3);
		
		// Print the result
		for (int i=0; i<combinations.length; ++i) {
			System.out.print("#" + (i+1) + ":\t");
			for (int j=0; j<combinations[i].length; ++j) {
				System.out.print(combinations[i][j]+"\t");
			}
			System.out.println();
		}
		
		assertEquals("The correct number of combinations must be generated", 20, combinations.length);
	}

}
